#ifndef _DBASE_H_
#define _DBASE_H_
#define DBASE_REQ_APPEND      0x01
#define DBASE_RESP_APPEND     0x101
#define DBASE_REQ_DELETE      0x02
#define DBASE_RESP_DELETE     0x102
#define DBASE_REQ_UPDATE      0x03
#define DBASE_RESP_UPDATE     0x103
#define DBASE_REQ_COPY        0x04
#define DBASE_RESP_COPY       0x104
#define DBASE_REQ_STATE       0x05
#define DBASE_RESP_STATE      0x105
#define DBASE_REQ_REPORT      0x06
#define DBASE_RESP_REPORT     0x106
#define DBASE_REQ_GET         0x07
#define DBASE_RESP_GET        0x107
#define DBASE_PATH_MAX        1024
#define DBASE_META_PATH       0x01
#define DBASE_CHUNK_SIZE      4194304
/* dbase request */
typedef struct _DBHEAD
{
    short       flag;
    short       status;
    int         cmd;
    int         length;
    uint64_t    id;
}DBHEAD;
/* dbase */
typedef struct _DBASE
{
    void *db;
    void *state;
    int fd;
    int port;
    int ip;
    char host[DBASE_HOST_MAX];
}DBASE;
DBASE *dbase_open(char *host, int port);
/* dbase check exists */
int dbase_exists(DBASE *dbase, char *filename);
/* dbase read */
int dbase_read(DBASE *dbase, char *filename, char *data, int ndata, off_t offset);
/* delete */
int dbase_delete(DBASE *dbase, char *filename);
/* dbase new file */
int dbase_create(DBASE *dbase, char *filename, char *data, int ndata);
/* dbase update data */
int dbase_update(DBASE *dbase, char *filename, char *data, int ndata);
/* copy from file */
int dbase_copy(DBASE *dbase, char *filename, char *localfile);
/* dump to file */
int dbase_dump(DBASE *dbase, char *filename, char *localfile);
/* dbase close */
int dbase_close(DBASE *dbase);
#endif
